// CGameBrowserNavigationBar.h : main header file for the NavigationBar
//

#pragma once

//#include "StandardHostViewPreview.h"

class CGameBrowserNavigationBar:public CWnd
{
      DECLARE_DYNAMIC(CGameBrowserNavigationBar)

      //Item type
      typedef enum _NavigateItemType
      {
          eNIT_NULL,
          eNIT_CascadeButton,
          eNIT_TileButton,
          eNIT_ListFilesButton,
          eNIT_CloseButton,
          eNIT_FileTab,
      }NavigateItemType;

      //Item Info
      typedef struct _TabItemInfo
      {
          NavigateItemType eItemType;
          HWND hwnd;
          CString strFullCaption;
          CString strShowCaption;
          BOOL bActive;
          BOOL bMouseHovered;
          CRect rPosition;
          int  nTabWidth;
          BOOL bShowOnTab;
      }TabItemInfo,*PTabItemInfo;

      // [ Constructors / Destructors... ]
public:
    CGameBrowserNavigationBar();
    ~CGameBrowserNavigationBar();


	// [ Accessors / Manipulators... ]
public:
    //MainFram RecalcLayout
    void MainFramRecalcLayout();

    //Create 
    BOOL CreateNavigateBar(CWnd *pParent,UINT nID);

    //Open,New document
    BOOL OnMDIChildCreate(HWND hwnd);
    //Close Document
    BOOL OnMDIChildDestory(HWND hwnd);

 
private: 
    // [ Private Method... ]
    void DeleteButtonItemInfo();
    int  GetAllOpendFileIndexByHwnd(HWND hwnd);
    int  GetCurrentShowOnNavIndexByHwnd(HWND hwnd);
    int  GetShowOnTabIndexByHwnd(HWND hwnd);
    void PaintOnMemoryDC(CDC &dcmemery);
    void DrawToolButtons(CDC &dc);
    void DrawFilesTab(CDC &dc);
    void DrawActiveFileTab(CDC &dc,PTabItemInfo pItem);
    void DrawDeActiveFileTab(CDC &dc,PTabItemInfo pItem);

    void DrawRectangle(CRect &rc,CDC &dc);
    
    PTabItemInfo GetActiveOpendFileItemInfo();
    
    void RecalcLayoutTabitem();
    void FileActiveChanged(PTabItemInfo pItemInfo);
    void CaculateWidthForTabItem(PTabItemInfo pItemInfo);
    void IdleCheckMousePositino();

    //executive command
    void OnCascadeWindow();
    void OnTileWindow();
    void OnFileListMenu(PTabItemInfo pItemInfo,CPoint pt);
    void OnFileTabClicked(PTabItemInfo pItemInfo);

    //for preview
    //ToolTip operation
    void ShowToolTip(BOOL bVisible,int xPos = 0,int yPos = 0);

    //Support to invisible navigation bar when no doc opened
    void CheckToShowNavigationBar(BOOL bOpenDoc);
     
private:
  // [ Private Members... ]

    CSize m_NavigateBarSize;
    //Save all opened tab;
    CArray<PTabItemInfo> m_arrayAllOpendFileTabItemInfo;
    //Save Current arranged tab
    CArray<PTabItemInfo> m_arrayCurrentArrangedFiles;
    //Save All visible tab
    CArray<PTabItemInfo> m_arrayShowOnTabItemFiles;
    //Save left button 
    CArray<PTabItemInfo> m_arrayButtonItemInfo;
    typedef CMap<HWND,HWND,PTabItemInfo,PTabItemInfo> CMapHwndToTabInfo;
    CMapHwndToTabInfo m_hwndToTabItemInfo;

    CWnd * m_pActiveChildWnd;   
    int m_nButtonWidth;   
    BOOL m_bNeedToForceRecalcLayout;

   
    PTabItemInfo    m_pCurrentCloseButton;
    PTabItemInfo m_currentMoseHoverTabItem;

    //For Preview
    //CStandardHostViewPreview m_toolTip;
    BOOL m_bVisible;

protected:
    // [ Protected Members... ]
    DECLARE_MESSAGE_MAP()

    virtual BOOL OnCommand(WPARAM wParam,LPARAM lParam);

    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);

    afx_msg void OnPaint();

    //Assign size from parent
    afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM);

    afx_msg LRESULT OnMenuSelectedChanged(WPARAM wParam,LPARAM lParam);

    //Mouse message
    afx_msg void OnMouseMove( UINT, CPoint);
    afx_msg void OnLButtonUp( UINT nFlags,CPoint point);

    //Size
     afx_msg void OnSize(UINT nType, int cx, int cy);


};